Purge 6 MB of bloat from registry.json
#2179
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
registry.json
file must be loaded and parsed before CKAN can do anything (CLI, GUI, etc.). Currently this file is about 21 MB and takes about 2 seconds to load on an SSD. Nearly 6 MB of it just sets assorted properties tonull
. But guess what value the deserializer uses if the property is absent? Yep:null
. So those properties don't need to be there.This pull request marks all the
JsonProperty
attributes that have at least onenull
value inregistry.json
withNullValueHandling = NullValueHandling.Ignore
, which means that if the value isnull
, it will not be printed to the file. When the properties are notnull
, they will be saved and loaded normally. The file will load the same and CKAN will work the same either way.Total change: 5856696 bytes, or 5.86 MB, or 27.6% of the current file size. This may yield a noticeable performance improvement on systems where
registry.json
is stored on a slower disk. (I don't think it's a straight 25% speed-up because the deserializer still needs to create the same objects and so on.)There are still
"ksp_version":null
properties in my registry for a few mods with no version requirements. I think this is due to some custom deserialization code adjusting things independently of the attributes. It seems harmless for now.Inspired by code review of #1888.